<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>WebOffice控件打开一个WORD文件</title>
	<#assign base=request.contextPath  />
    <base id="basePath" href="${base}">
    <link rel="stylesheet" href="${base}/css/demo.css" type="text/css">
    <link rel="stylesheet" href="${base}/css/zTreeStyle.css" type="text/css">
    <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery.ztree.excheck.js"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery.ztree.exedit.js"></script>
<script type="text/javascript">
var pfile = "a.doc"; //word的文件名
var varpath = decodeURI(window.location.pathname);
var strRoot = varpath.substring(1,varpath.lastIndexOf('/')+1);//取得打开、保存路径 
if (strRoot =='')strRoot = varpath.substring(1,varpath.lastIndexOf('\\')+1);
var strOpenUrl = "${lujing}"; //取得打开路径和文件名
var strSaveUrl = "${lujing}"; //取得保存路径和文件名
strSmartUrl = "WebOffice://|Officectrl|" + window.location.href;//开启智能窗模式
function WebOpen()
{

	obj = document.getElementById('WebOffice');//获得控件对象
	if (obj)setTimeout('openfile()',100);//等待控件初始化完毕，时间可以根据网络速度设定。
}
function openfile()
{
	document.getElementById('WebOffice').Open(strOpenUrl,true,"Word.Document","","");
}
function WebSave()
{  
	document.getElementById('WebOffice').ActiveDocument.SaveAs(strSaveUrl);
	alert('表单数据和office文档保存成功!');
	location.reload(); 
} 
function SmartOpen()
{
	location.href=strSmartUrl;
}
</script> 
</head>
<body topmargin=0 leftmargin=0 onload="javascript:WebOpen();">
<div style="text-align:left;font-size:15px;">
<input type="button"  class="button" value="保存" style="width:80px" onclick="WebSave();"/>
<script language=javascript src="${base}/js/webofficetip.js" charset="utf-8"></script>
<a href="javascript:SmartOpen();">智能窗口链接</a>
</div>
<script language=javascript src="${base}/js/webofficeocx.js" charset="utf-8"></script>

</body></html>
